#ifndef __IF_SOC_UART_H__
#define __IF_SOC_UART_H__

#include <functional>
#include <stdint.h>
#include "soc/iperipheral.h"
#include "soc/soc_comm_def.h"


/// @brief IF SOC UART
class IF_SOC_Uart : public IPeripheralEx<IF_SOC_Uart, SOC_UART_MAX>
{
public:
    using DATA_RECEIVED_CB = std::function<void(IF_SOC_Uart &sender, uint8_t c)>;
    using DATA_RECEIVED_CB_DMA = std::function<void(IF_SOC_Uart &sender, uint8_t *buffer, int size)>;

public:
    virtual void WriteByte(uint8_t value) = 0;
    virtual void Write(const uint8_t *buf, int len) = 0;
    virtual void Write(const char *str) = 0;
    virtual void Write(const std::string &str) = 0;
    virtual void WriteLine(const char *str) = 0;
    virtual void WriteLine(const std::string &str) = 0;
    
    virtual int ReadByte() = 0;
    virtual void StartReceive_IT() = 0;

    //DMA
    virtual void WriteDMA(const uint8_t *buf, int len) = 0;
    virtual bool IsDMAIdle() = 0;

    //
    virtual void SetDataReceivedCallBack(const DATA_RECEIVED_CB &func) = 0;
    virtual void SetDataReceivedCallBack_DMA(const DATA_RECEIVED_CB_DMA &func) = 0;
    virtual void RaiseDataReceivedCallBack() = 0;
    virtual void RaiseIdleEventCallBack() = 0; //FOR DMA
};

#endif // __IF_SOC_UART_H__
